#include <iostream>
#include <vector>

using namespace std;

int binarySearch(vector<int>& nums, int target) {
    int left = 0;
    int right = nums.size() - 1;

    while (left <= right) {
        int mid = left + (right - left) / 2;

        if (nums[mid] == target) {
            return mid;
        } else if (nums[mid] < target) {
            left = mid + 1;
        } else {
            right = mid - 1;
        }
    }

    return -1; 
}

int main() {
    vector<int> nums = {2, 4, 6, 8, 10, 12, 14};

    int target;
    cout << "请输入要查找的目标值：";
    cin >> target;

    int index = binarySearch(nums, target);

    if (index != -1) {
        cout << "目标值 " << target << " 在数组中的下标为：" << index << endl;
    } else {
        cout << "目标值 " << target << " 不存在于数组中" << endl;
    }

    return 0;
}